<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">

            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form layuimini-form" action="">

                        <input type="hidden" name="id" />
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label required">分类名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="classIficationName" lay-verify="required" lay-reqtext="请输入标题" placeholder="请输入用户名" value="" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label ">英文别名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="englishAlias" lay-reqtext="请输入标题" placeholder="请输入用户名" value="" class="layui-input">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <input type="hidden" name="categoryParentId" />
                                <input type="hidden" name="hierarchy" />
                                <label class="layui-form-label ">上级分类</label>
                                <div class="layui-input-inline">
                                    <div class="layui-unselect layui-form-select downpanel">
                                        <div class="layui-select-title">
                                            <input type="text" name="categoryParent" placeholder="选择分类" readonly="true" name="keleyicom" value="" class="layui-input"><i class="layui-edge"></i>
                                            <dl class="layui-anim layui-anim-upbit">
                                                <dd>
                                                    <ul id="classtree"></ul>
                                                </dd>
                                            </dl>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">栏目图片</label>
                            <div class="layui-input-block">
                                <div class="layui-upload-drag " id="test10">
                                    <i class="layui-icon">&#xe67c</i>
                                    <p>点击上传，或将文件拖拽到此处</p>
                                    <div class="layui-hide" id="uploadDemoView">
                                        <hr>
                                        <img src="" alt="上传成功后渲染" style="max-width: 196px">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">跳转链接</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="open" lay-skin="switch" lay-filter="switchTest" title="开关">
                            </div>
                        </div>
                        <div class="layui-form-item" id="hrefdata" style="display: none;">
                            <label class="layui-form-label">链接</label>
                            <div class="layui-input-block">
                                <input type="text" name="externalLinks" placeholder="请输入链接" lay-verify="url" value="" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label ">SEO标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="seoTitle" lay-reqtext="请输入标题" placeholder="请输入用户名" value="" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label ">SEO关键词</label>
                            <div class="layui-input-block">
                                <input type="text" name="seoKeyword" lay-reqtext="请输入关键词" placeholder="请输入用户名" value="" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label ">SEO描述</label>
                            <div class="layui-input-block">
                                <input type="text" name="seoDescribe" lay-reqtext="请输入描述" placeholder="请输入用户名" value="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label ">排序</label>
                            <div class="layui-input-block">
                                <input type="text" name="sort" lay-reqtext="请输入描述" placeholder="请输入用户名" value="" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-block">
                                <textarea name="remarks" placeholder="请输入内容" class="layui-textarea"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">是否有效</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="effective" lay-skin="primary" title="有效" checked="">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="demo1">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>



            </div>
        </div>
    </div>
    <script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
        layui.use(['form', 'layedit', 'laydate', 'tree', 'upload', 'element', 'laydate'], function() {
            var $ = layui.jquery,
                form = layui.form,
                layer = layui.layer,
                layedit = layui.layedit,
                laydate = layui.laydate,
                tree = layui.tree,
                element = layui.element,
                upload = layui.upload;


            //拖拽上传
            upload.render({
                elem: '#test10',
                url: 'https://httpbin.org/post' //改成您自己的上传接口
                    ,
                done: function(res) {
                    layer.msg('上传成功');
                    layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.files.file);
                    console.log(res)
                }
            });
            //渲染树
            tree.render({
                //绑定元素
                elem: '#classtree',
                //添加数据
                isopen: true,
                data: [{
                    //一级菜单
                    title: '江西',
                    spread: true,
                    id: 12,
                    //二级菜单
                    children: [{
                        title: '南昌',
                        id: 121,
                        children: [{
                            //三级菜单
                            title: '高新区'
                                //…… //以此类推，可无限层级
                        }]
                    }]
                }, {
                    title: '陕西',
                    spread: true,
                    id: 13,
                    children: [{
                        title: '西安',
                        id: 131,
                    }]
                }],
                click: function(obj) {
                    //执行节点点击重载
                    console.log(obj.data.title)
                    $("input[name='categoryParent']").val(obj.data.title)
                }
            });
            //下拉树点击事件
            $(".downpanel").on("click", ".layui-select-title", function(e) {
                $(".layui-form-select").not($(this).parents(".layui-form-select")).removeClass("layui-form-selected");
                $(this).parents(".downpanel").toggleClass("layui-form-selected");
                layui.stope(e);
            }).on("click", "dl i", function(e) {
                layui.stope(e);
            });


            //监听指定开关
            form.on('switch(switchTest)', function(data) {

                if (this.checked) {
                    $('#hrefdata').show()
                } else {
                    $('#hrefdata').hide()
                }


            });

            //监听提交
            form.on('submit(demo1)', function(data) {
                console.log(data)
                layer.alert(JSON.stringify(data.field), {
                    title: '最终的提交信息'
                })
                return false;
            });

        });
    </script>
</body>

</html>